package com.csdj.t301.cloud;

import com.csdj.t301.cloud.entity.MapEntity;
import com.csdj.t301.cloud.entity.Person;
import com.csdj.t301.cloud.entity.User;
import com.csdj.t301.cloud.mapper.UserMapper;
import com.csdj.t301.cloud.uitls.RelfectUtil;
import com.csdj.t301.cloud.uitls.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.*;


/**
 * author:cloud
 * date:2021/1/20 0020
 **/
public class Test {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("name","t301");
        map.put("address","csdj");
        map.put("photo","13215496");
        Object obj = RelfectUtil.mapToEntity(map,"com.csdj.t301.cloud.entity.MapEntity");
        if(obj == null){
            System.out.println("转换失败");
        }else{
            if(obj instanceof MapEntity){
                MapEntity me = (MapEntity)obj;
                System.out.println(me.say());
            }
        }
//        SqlSession session = SqlSessionUtil.getSession();
//        UserMapper userMapper = session.getMapper(UserMapper.class);
//        List<User> list = userMapper.findAllUsers();
//        for(User user : list){
//            System.out.println(user.getUserName());
//        }
//        session.close();

    }

    public static int sum(int i){
        if(i > 0){
            return i + sum(i-1);
        }else{
            return 0;
        }
    }

    public static void change(Person person,int num){
        person.setName("li");
        num = 10000;
    }

    public static int maxLength(String s){
        int max = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            String c = String.valueOf(s.charAt(i));
            if(sb.indexOf(c)>-1){
                sb = new StringBuilder(sb.substring(sb.indexOf(c)+1));
                sb.append(c);
           }else{
               sb.append(c);
           }
            if(sb.length()>max){
                max = sb.length();
            }
        }
        if(max>sb.length()){
            return max;
        }else{
            return sb.length();
        }
    }
    class ListNode{
        int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    }
    public  ListNode addTwoNumbers(ListNode l1, ListNode l2){
        ListNode result = null;
        ListNode a = l1.next;
        ListNode b = l2.next;
        int add = 0;
        while(true){
            if(a == null && b == null){
                if(add == 1){
                    result.next = new ListNode(1);
                }else{
                    break;
                }
            }else if(a != null && b != null){

            }else{
                
            }
        }
        return null;
    }
}
